 <SCRIPT type=text/javascript>
	$(function() {
		$("#tabs").tabs().find(".ui-tabs-nav").sortable({axis:'x'});

		$('.selectAll').click(function(){	
			var value = $(this)[0].id;	
			if (value == "checkAll") {
					 $('.check_class').each(function(i) {
					    	// activamos				    		
					    	$(this).attr("checked","checked");				    	
					    	
					 })
			} else if (value == "checkAdminAll") {
				 $('.check_admin_class').each(function(i) {
				    	// activamos 
				    	$(this).attr("checked","checked");
				 })	
			}	 
		
		});

		
	});
</SCRIPT>
 <div class="kt-g1">
		<div class=" kt-right">
	   		<ul class="lst-tabs">
	   		 	<li id="icon-views" class="active"><a href="<?php echo $this->base.'/admin/ktviews' ?>"><span class="icon"></span><?php __('vistas'); ?></a></li>
			</ul>	  
		</div>
</div>
<div class="kt-md-content">
	 <?php if (isset($configuration)){ ?>
		<div class="kt-md-configuracion">
			 	
			 		<div class="bd lst-form">
				 	  <table>
				 	  <tr>
					 	  <td> <p>  <strong> <?php __('configuration_name') ?> </strong></p>
					 	       <p> <?php echo $configuration["name"] ?></p>
					 	  </td>     
					 	  <td> 
					 	    <p> <strong><?php __('configuration_directory') ?> </strong></p>
					 	    <p> <?php echo $configuration["directory"] ?></p>
					 	  </td>	 	  
				 	  </tr>	 	  
				 	  </table> 
				</div>
		</div>
<?php } ?>
 <?php if (!is_writable(VIEWS)) { ?>					
		  		<div class="kt-md  configuration_error">
		  		<div class="bd">
						<p class="error_msg"> <?php  __('Your directory  is NOT writable.'); ?> 
				  				<?php  __('generation  will not work correctly'); ?>
				 		</p> 
				 </div>
			 	</div>
<?php	} ?>

<?php echo $form->create("Ktview", array('action' => 'admin_norender')); ?>
<div class="kt-md">
		<div class="hd">
			<p id="icon-tools" class="icon32"></p>
			<h2><?php __('view_generate') ?> - <?php echo $selected_view ?></h2>
			
		</div>
	
<div class="bd">	
	<div id="tabs">
	   <ul>
	      <li><a href="#tabs-1"><?php __('methods') ?></a></li>	     
	      <li><a href="#tabs-2"><?php __('fields_customization') ?></a></li>
	   </ul>
	   
	
	<div id="tabs-1"> 
	
		<div class="kt-g2a">
			<div class="kt-gu first-g">
					<div class="kt-md">
					<div class="hd">
						<h3><?php __('methods') ?></h3>
						<h5><?php __('methods_legend_views') ?></h5>
					</div>			
					<div class="bd">
								
						<div class="lst-form">
						<fieldset>
						<table>
						<tr class="form-field">
							<td>					
								<p>
									<?php echo $form->label('usercheck][index]',__('index_views',true),array('class'=> 'label_check')); ?>
									<?php echo $form->checkbox('usercheck][index]',array('class'=> 'check_class')); ?>
								</p> 					
							</td>
							<td>
								<p>
									<?php echo $form->label('usercheck][add',__('add_views',true),array('class'=> 'label_check')); ?>
									<?php echo $form->checkbox('usercheck][add',array('class'=> 'check_class')); ?>
								</p> 						
							</td>
						</tr>				
						<tr class="form-field">
							<td>
								<p>
									<?php echo $form->label('usercheck][view',__('view_views',true),array('class'=> 'label_check')); ?>
									<?php echo $form->checkbox('usercheck][view',array('class'=> 'check_class')); ?>
								</p> 				
							</td>
							<td>
								 <p>
									 <?php echo $form->label('usercheck][edit', __('edit_views',true),array('class'=> 'label_check')); ?>
									<?php echo $form->checkbox('usercheck][edit',array('class'=> 'check_class')); ?>
								</p> 			 				
							</td>
						</tr>
		
						</table>
						</fieldset>
						<fieldset>
							<table>
							<tr class="form-field">
								<td>					
									<p>
										<label for="checkAll"><? echo __('Seleccionar todos'); ?></label>
										<input  type="checkbox" id="checkAll" class="selectAll" />
									</p> 					
								</td>
							</tr>				
							
			
							</table>
							</fieldset>
						</div>						
					</div>		
				</div>
			</div>
			<div class="kt-gu">
				<div class="kt-md">
			<div class="hd">
				<h3><?php __('methods_admin_views') ?></h3>
				<h5><?php __('methods_admin_views_legends') ?></h5>
			</div>			
			<div class="bd">			
				<div class="lst-form">
				<fieldset>
				<table>
				<tr class="form-field">
					<td>					
						<p>
							<?php echo $form->label('admincheck][index]', __('admin_index',true),array('class'=> 'label_check')); ?>
							<?php echo $form->checkbox('admincheck][index]',array('class'=> 'check_admin_class')); ?>
						</p> 					
					</td>
					<td>
						<p>
							<?php echo $form->label('admincheck][add',__('admin_add',true),array('class'=> 'label_check')); ?>
							<?php echo $form->checkbox('admincheck][add',array('class'=> 'check_admin_class')); ?>
						</p> 						
					</td>
				</tr>				
				<tr class="form-field">
					<td>
						<p>
							<?php echo $form->label('admincheck][view',__('admin_view',true),array('class'=> 'label_check')); ?>
							<?php echo $form->checkbox('admincheck][view',array('class'=> 'check_admin_class')); ?>
						</p> 				
					</td>
					<td>
						 <p>
							 <?php echo $form->label('admincheck][edit',__('admin_edit',true),array('class'=> 'label_check')); ?>
							 <?php echo $form->checkbox('admincheck][edit',array('class'=> 'check_admin_class')); ?>
						</p> 			 				
					</td>
				</tr>

				</table>
				</fieldset>
				<fieldset>
				<table>
				<tr class="form-field">
					<td>					
						<p>
							<label for="checkAdminAll"><? echo __('Seleccionar todos'); ?></label>
							<input  type="checkbox" id="checkAdminAll" class="selectAll" />
						</p> 					
					</td>
				</tr>				
				

				</table>
				</fieldset>
				</div>						
			</div>		
		</div>
			</div>
		</div>
	
		
	</div>	
	

	<div id="tabs-2">
	<div class="kt-md">
		<div class="hd">
		<h3><?php __('fields_customization') ?></h3>

		<h5><?php __('fields_customization_legend') ?></h5>
		</div>			
		<div class="bd">			
			<div class="lst-form kt-md-group  lst-fields">	
			<table>
				<tr class="form-field">
					<th> <?php __('field_name') ?> </th>
					<th> <?php __('database_type') ?> </th>
					<th> <?php __('validate_type') ?> </th>				
				</tr>
				
				<?php foreach ($fields as $field){ ?>
				<tr class="form-field">
					<td><?php echo $form->label("valid][".$field['name'], $field['name']); ?></td>
					<td><?php echo $field['type']; ?></td>
					<td><?php echo $form->select("valid][".$field['name'], $selector ,  null, false); ?></td>				
				</tr>			
				<?php } ?>			
			</table>
			 		
			</div>	
		</div>		
	  </div>
    </div>	
	</div> <!-- fin tabs -->	
	
	<?php echo $form->input('selected_view', array('type' => 'hidden','value' => $selected_view));?>
	<?php echo $form->input('userDbConfig', array('type' => 'hidden','value' => $userDbConfig));?> 
	<p class="submit"><?php echo $form->submit(__('generate',true)); ?></p>		
	<?php echo $form->end();?>
</div>	
</div>	
</div>